package de.hska.algo.labor2010.strecken;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.imageio.ImageIO;

import junit.framework.Assert;

//to Do: epsilon bei : isPointInRange und istPointinGridPart!

public class Main {

	public static void main(String[] args) {
//		/*
//		 * 0: (46.12462708724391 , 395.64739759057835) (92.29273394720094 ,
//		 * 58.584153158369176) 2: (57.49040405178668 , 206.20378036632337)
//		 * (183.5106639342563 , 394.72724452272206)
//		 */
		 TangentLines test = new TangentLines(250 ,500);

	
		ArrayList<Line> lines = test.getLines();


		IntersectLinesBruteForce bruteForce = new IntersectLinesBruteForce();
		ArrayList<Point> intersections = (ArrayList<Point>) bruteForce
				.bruteForceIntersect(lines);
		System.out.println(lines.size() + " Lines, found: "
				+ intersections.size() + " intersections");
		Grid grid = new Grid();

		ArrayList<Point> intersections2 = (ArrayList<Point>) grid
				.intersectAndInitialize(lines,25);
		System.out.println(lines.size() + " Lines, found: "
				+ intersections2.size() + " intersections");
		System.out.println("\n############################################");
		//System.out.println(grid);
		//System.out.println(test);
		MyImage img = new MyImage(1000);
		img.drawLines(lines);
		img.drawPoints(intersections);

		MyImage img2 = new MyImage(1000);
		img2.drawGrid(grid.getGrid(),false);
		img2.drawLines(lines);
		img2.drawPoints(intersections2);
		

		try {
			ImageIO.write(img.getIMG(), "png", new File("img.png"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		try {
			ImageIO.write(img2.getIMG(), "png", new File("img2.png"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// for(int i = 0; i < 50;i++){
		// System.out.println(test.getLines().get(i*20));
		// }

		// test = new TangentLines(100);
		// intersections = (ArrayList<Point>)
		// bruteForce.bruteForceIntersect(test.getLines());
		// System.out.println("100 Lines, found: " + intersections.size()
		// +" intersections");
		// test = new TangentLines(1000);
		// intersections = (ArrayList<Point>)
		// bruteForce.bruteForceIntersect(test.getLines());
		// System.out.println("1000 Lines, found: " + intersections.size()
		// +" intersections");
		// test = new TangentLines(10000);
		// intersections = (ArrayList<Point>)
		// bruteForce.bruteForceIntersect(test.getLines());
		// System.out.println("10000 Lines, found: " + intersections.size()
		// +" intersections");
		// ArrayList<Line> lines = new ArrayList<Line>();
		// IntersectLinesBruteForce bruteForce = new IntersectLinesBruteForce();
		// lines.add(new Line(3,4,1,1));
		// lines.add(new Line(1,1,5,5));
		// ArrayList<Point> intersections = (ArrayList<Point>)
		// bruteForce.bruteForceIntersect(lines);
		// System.out.println(intersections.size());

	}

}
